import com.baidu.aip.face.AipFace;
import com.ym.utils.ImageToBase64Util;
import org.jetbrains.annotations.NotNull;
import org.json.JSONObject;

import java.util.HashMap;

public class Sample {
    //设置APPID/AK/SK
    public static final String APP_ID = "119601557";
    public static final String API_KEY = "HP2cL8xniZfcU3a00zxToT5i";
    public static final String SECRET_KEY = "ub3vpErlozFAuQCu8G6N4gCU4l48TXOT";

    public static void main(String[] args) {
        // 初始化一个AipFace
        AipFace client = new AipFace(APP_ID, API_KEY, SECRET_KEY);

        // 调用接口
        String image = "392f8f051cd60424dfe8e497f988dbaf";
        String imageType = "FACE_TOKEN";
        String groupIdList = "testFace";
        String groupId = "testFace";
        String userId = "1";

        HashMap<String, String> options = getStringStringHashMap();
        options.put("appid", APP_ID);
        JSONObject res = client.videoSessioncode(options);
        System.out.println(res.toString(2));




        // 传入可选参数调用接口
        //HashMap<String, String> options = new HashMap<String, String>();
        //options.put("start", "0");
        //options.put("length", "50");


        // 组列表查询
        //JSONObject res = client.getGroupList(options);
        //System.out.println(res.toString(2));

    }

    @NotNull
    private static HashMap<String, String> getStringStringHashMap() {
        HashMap<String, String> options = new HashMap<>();

        // 人脸检测
        //JSONObject res = client.detect(image, imageType, options);
        //System.out.println(res);
        // 人脸搜索(识别登录)
        //JSONObject res = client.search(image, imageType, groupIdList, options);
        //System.out.println(res.toString(2));
        // 人脸注册
        //JSONObject res = client.addUser(image, imageType, groupId, userId, null);
        //System.out.println(res.toString(2));

        options.put("appid", "223245");
        return options;
    }
}
